package com.yochi.pictureseditor.effects.converters;

import java.util.Locale;

public class GammaConverter implements ParameterConverter {
	
	private static final long serialVersionUID = 5166325797583539833L;

	public double convert(double parameter) {
		if(parameter >= 0 && parameter <= 256) {					// returns 1 < x < 20
			return (-19.0f/256.0f)*parameter + 20.0f;
		}  /*else if(parameter > 256 && parameter <= 512) { */		// returns 1/20 < x < 1
			return (-0.95f/256.0f)*parameter + 1.95f;
	}
	
	public double convertInverse(double value) {
		return (256.0f/100.0f)*value + 256;
	}

	public String toDisplay(double parameter) {
		return String.format(Locale.FRANCE, "%.1f", (100.0f/256.0f)*parameter - 100.0f);
	}

}